package com.example.administrator.basedemos.activity;

import com.example.administrator.basedemos.R;
import com.example.administrator.basedemos.base.BaseActivity;
import com.example.administrator.basedemos.dagger2.Apiservice;
import com.example.administrator.basedemos.dagger2.Component.DaggerUserComponent;
import com.example.administrator.basedemos.dagger2.annotation.Dev;
import com.example.administrator.basedemos.dagger2.annotation.Release;
import com.example.administrator.basedemos.dagger2.moudle.UserMoudle;
import com.example.administrator.basedemos.utils.LogUtil;

import javax.inject.Inject;

import okhttp3.OkHttpClient;

/**
 * 创建者     ZCL
 * 创建时间   2018/3/12 17:37
 * 描述	      ${添加named获取不通的对象那么 凡是使用此类对象的 都要注明named告诉系统使用哪个方法 否则会报找不到}
 * <p>
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */

public class Dagger2Activity extends BaseActivity {
    private static final String TAG = "Dagger2";

//    @Inject
//    UserManger mUserManger;


    @Inject
    OkHttpClient mOkHttpClient;
    @Inject
    OkHttpClient mOkHttpClient1;

    @Inject
    @Dev
    Apiservice mApiserviceDev;

    @Inject
    @Release
    Apiservice mApiserviceRelease;

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
        //mUserManger = new UserManger(new Apiservice(), new UserStore(this));
        //mUserManger.register();
        //dagger2 无参数时候可以直接使用create  等于.builder().userMoudle(new UserMoudle()).build()
       // DaggerUserComponse.create().inject(this);
        //DaggerUserComponse.builder().userMoudle(new UserMoudle()).build().inject(this);
        //mApiservice.register();
        //因为moudle需要参数 所以必须使用builer

        //mUserManger.register();


        DaggerUserComponent.builder()
                .userMoudle(new UserMoudle(this))
                .appComponent(((MyApplication)getApplication()).getAppComponent())
                .build()
                .inject(this);

       LogUtil.util(TAG,"dev:"+mApiserviceDev);
        LogUtil.util(TAG,"release:"+mApiserviceRelease);

        LogUtil.util(TAG,"si:"+mOkHttpClient);
        LogUtil.util(TAG,"sii:"+mOkHttpClient1);


    }

    @Override
    public int setLayoutId() {
        return R.layout.activity_dagger;
    }
}
